var t = getApp(), e = (require("../../configs/config.js"), require("../../apis/api.js")), a = require("../../utils/util.js");

Page({
    data: {
        version:false,
        dialogShow: !1,
        platform: "ios",
        memberType: "",
        iosPayEnabled: !1,
        payEnabled: !1,
        categoryList: [],
        articleList: []
    },
    onLoad: function() {
        this.setData({
            platform: a.getPlatform(),
            memberType: a.getMemberType()
        });
    },
    onShow: function() {
      const accountInfo = wx.getAccountInfoSync();
      var version=accountInfo.miniProgram.envVersion=="release";//判断是否为线上版本
      console.log(version,"versionversion")
        this.setData({
            version:version,
            memberType: a.getMemberType()
        }), this.getCategoryList(), this.getArticleList(), this.getClient(), t.login();
    },
    onPullDownRefresh: function() {
        this.setData({
            memberType: a.getMemberType()
        }), this.getCategoryList(), this.getArticleList(), this.getClient(), t.login();
    },
    onShareAppMessage(e) {
      return {
          title: "恋爱小课堂----单身的你值得拥有",
          imageUrl: 'https://img2.baidu.com/it/u=859306311,1534966596&fm=253&fmt=auto&app=138&f=JPEG?w=594&h=500',
      }
  },
  onShareTimeline() {
      console.log('分享朋友圈')
      return {
          title: "恋爱小课堂----单身的你值得拥有",
          imageUrl: 'https://img2.baidu.com/it/u=859306311,1534966596&fm=253&fmt=auto&app=138&f=JPEG?w=594&h=500',
      }
  },
    onSearchTap: function() {
        wx.navigateTo({
            url: "/pages/search/search"
        });
    },
    onSearchItemTap: function(t) {
        wx.navigateTo({
            url: "/pages/search/search?keyword=" + t.currentTarget.dataset.keyword
        });
    },
    onTopicItemTap: function(t) {
        wx.navigateTo({
            url: "/pages/chatList/chatList?categoryId=" + t.currentTarget.dataset.id + "&title=" + t.currentTarget.dataset.name
        });
    },
    onTopTap(){
      wx.navigateToMiniProgram({
        appId: 'wx7d8dfbb0fd9b7857',
      })
    },
    onCombatMoreTap: function() {
        wx.switchTab({
            url: "/pages/combat/combat"
        });
    },
    onCombatItemTap: function(t) {
        "vip会员" != this.data.memberType && this.data.payEnabled ? "ios" != this.data.platform || this.data.iosPayEnabled ? this.setData({
            dialogShow: !0
        }) : wx.showModal({
            title: "提示",
            content: "由于相关规范，iOS功能暂不可用",
            confirmText: "确定",
            success: function(t) {
                t.confirm;
            }
        }) : wx.navigateTo({
            url: "/pages/articleDetail/articleDetail?articleId=" + t.currentTarget.dataset.id
        });
    },
    onHotTap: function() {
        wx.switchTab({
            url: "/pages/discover/discover"
        });
    },
    getClient: function() {},
    getCategoryList: function() {
        var t = this, a = {};
        e.getChatCategoryList(a).then(function(e) {
            t.setData({
                categoryList: e.responseData.categoryList
            });
        });
    },
    getArticleList: function() {
        var t = this, a = {
            pageCount: 1,
            pageSize: 9
        };
        e.getArticleList(a).then(function(e) {
            t.setData({
                articleList: e.responseData.articleList
            });
        });
    }
});